package org.cskt.sl.ebank.service.impl;

import java.util.Date;
import java.util.List;

import org.cskt.sl.ebank.dao.WithDrawMapper;
import org.cskt.sl.ebank.entity.CommonExample;
import org.cskt.sl.ebank.entity.WithDraw;
import org.cskt.sl.ebank.service.WithDrawService;
import org.cskt.sl.util.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
/**
 * 提现详细 service
 * @author guddqs
 *
 */
public class WithDrawServiceImpl implements WithDrawService{

	@Autowired
	private WithDrawMapper mapper;
	
	@Override
	public int countByExample(CommonExample example) {
		return mapper.countByExample(example);
	}

	@Override
	public int addWithDraw(WithDraw record) {
		return mapper.insertSelective(record);
	}

	@Override
	public List<WithDraw> findWithDrawPageList(CommonExample example, Pager pager) {
		if(pager!=null){
			if(pager.getCurrentPage()!=null){
				int first=(pager.getCurrentPage()-1)*pager.getPageSize();
				int max=pager.getPageSize();
				return mapper.selectByExample(example, first, max);
			}
		}
		return null;
	}

	@Override
	public WithDraw getWithDrawById(Integer wid) {
		return mapper.selectByPrimaryKey(wid);
	}

	@Override
	public int updateStateById(Integer id) {
		WithDraw record=new WithDraw();
		record.setWid(id);
		record.setApplytime(new Date());
		return mapper.updateByPrimaryKeySelective(record);
	}

}
